using System;
using System.Text;
using System.Runtime;
using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;



[ StructLayout( LayoutKind.Sequential , Pack = 1 ) ]
public unsafe struct SANpcData 
{
	public int		Texture;
	
	public short	ID;
	public byte		Px;
	public byte		Py;
	
	public short	X;
	public short	Y;
	
	public int		Fall;
	
	public fixed byte Name[ GameDefine.MAX_NAME ];
};


[ StructLayout( LayoutKind.Sequential , Pack = 1 ) ]
public unsafe struct SACreatureBaseData
{
	public short	HP;
	public short	MAXHP;
	public short	MP;
	public short	MAXMP;
	
	public short	Attack;
	public short	Defence;
	public short	Quick;
	public short	Charm;
	
	public byte		Earth;
	public byte		Water;
	public byte		Fire;
	public byte		Wind;
	

};



[ StructLayout( LayoutKind.Sequential , Pack = 1 ) ]
public struct SATeamPlayer 
{
	public int		GUID;
	
	public short	HP;
	public short	MAXHP;
	public short	MP;
	public short	MAXMP;
};



[ StructLayout( LayoutKind.Sequential , Pack = 1 ) ]
public unsafe struct SACreatureData
{
	public SACreatureBaseData Base;


	public int		ID;
	public int		ActionID;

	public fixed byte Name[ GameDefine.MAX_NAME ];
	
	public byte		Role;
	public byte		Color;
	public byte		Eye;
	public byte		Mouth;

	public byte		RidingPet;
	public byte		WeaponType;
	public byte		unknow1;
	public byte		unknow2;

	public short	Vitality;
	public short	Strength;
	public short	Toughness;
	public short	Dexterity;
	
	public short	Type;
	public short	DP;
	
	public int		EXP;
	public int		NEXTEXP;
	
	public short	LevelUpPoint;
	public byte		Level;
	public byte		LevelPRO;


	public unsafe void setPlayerData( SAPlayerData data )
	{
		ID = data.GUID;

		Role = data.Role;
		Color = data.Color;
		RidingPet = data.RidingPet;
		WeaponType = data.WeaponType;

		Level = data.Level;
		LevelPRO = data.LevelPRO;

		Base.HP = data.HP;
		Base.MAXHP = data.MAXHP;
		Base.MP = data.MP;
		Base.MAXMP = data.MAXMP;


		fixed( byte* pb = Name )
		{
			byte[] buf = new byte[ GameDefine.MAX_NAME ];

			for ( int i = 0; i < GameDefine.MAX_NAME; i++ )
			{
				pb[ i ] = data.Name[ i ];
				buf[ i ] = data.Name[ i ];
			}

			string str = Encoding.UTF8.GetString( buf );
			Debug.LogError( str );

		}
	}




};


[ StructLayout( LayoutKind.Sequential , Pack = 1 ) ]
public struct SAPetData
{
	SACreatureData	Data;
	
	short			ID;
	short			Photo;
};



